// Created by wxx on 2021/10/15.
#include <iostream>
#include <vector>

using namespace std;

/**
 * 执行用时：12 ms, 在所有 C++ 提交中击败了88.42%的用户
 * 内存消耗：5.8 MB, 在所有 C++ 提交中击败了61.26%的用户
 */

class Solution {
public:
    int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    bool is_leap(int year) {
        return year % 4 == 0 && year % 100 || year % 400 == 0;
    }

    int dayOfYear(string date) {

        int year, month, day;
        sscanf(date.c_str(), "%d-%d-%d", &year, &month, &day);
        int res = month > 2 ? is_leap(year) : 0;
        for (int i = 1; i < month; i++) res += months[i];
        return res + day;
    }
};

int main() {

    cout << Solution().dayOfYear("2000-03-09") << endl;  // 69
    cout << Solution().dayOfYear("2009-03-09") << endl;  // 68

    return 0;
}
